package com.my.utils;

import com.my.constant.Constant;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @Author coderMy
 * @Date 2021/3/30
 */
public class RequestTokenUtil {

    public static String getRequestToken(){

        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        if (servletRequestAttributes==null){
            return null;
        }
        String token = servletRequestAttributes.getRequest().getHeader(Constant.HEADER_TOKEN_KEY);
        return token;
    }

}
